<?php
/**
 * Created by JetBrains PhpStorm.
 * User: admin
 * Date: 18.10.12
 * Time: 19:57
 * To change this template use File | Settings | File Templates.
 */
class User_Form_Registration extends Zend_Form
{
    public function init()
    {
        $this->setName('registration_form');

        $email = new Zend_Form_Element_Text('email');
        $email->setLabel('Email:')
            ->addValidator('EmailAddress')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->addValidator('Db_NoRecordExists', false, array('users', 'email'))
            ->setRequired(true);
        $this->addElement($email);

        $login = new Zend_Form_Element_Text('login');
        $login->setLabel('Login:')
            ->addValidator('NotEmpty')
            ->setRequired(true)
            ->addFilter('StringTrim')
            ->addPrefixPath('Mylab_Validators', 'Mylab/Validators', 'validate')
            ->addValidator('LoginNotMatch')
            ->addValidator('StringLength',   false, array(4, 16));

        $this->addElement($login);

        $password = new Zend_Form_Element_Password('password');
        $password->setLabel('Пароль:')
            ->setRequired(true)
            ->addValidator('NotEmpty');

        $this->addElement($password);

        $passwordcn = new Zend_Form_Element_Password('passwordcn');
        $passwordcn->setLabel('Повторите пароль:')
            ->setRequired(true)
            ->addValidator('NotEmpty')
            ->addPrefixPath('Mylab_Validators', 'Mylab/Validators', 'validate')
            ->addValidator('PasswordConfirm');

        $this->addElement($passwordcn);

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel('Вход');
        $this->addElement($submit);

    }
}
